{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('banjori', 'emyzthoodivettewl'), ('rovnix', 'f1nyx3252iqxzc2kc3'), ('benign', 'sharepoint'), ('rovnix', 'bvlxpq4c67cyxslekt'), ('emotet', 'pvoagpevglmdfnqh'), ('banjori', 'bdusorcajanunal'), ('banjori', 'vprqinalcentricem'), ('emotet', 'gibwkbqbtwfakrvx'), ('benign', 'excelgratis'), ('banjori', 'dryxardenslavetusul')]\n"
     ]
    }
   ],
   "source": [
    "import pickle\n",
    "from random import shuffle\n",
    "fp = open(\"./data_set/all_data.pkl\", 'rb')\n",
    "date_set = pickle.load(fp)\n",
    "shuffle(date_set)\n",
    "print(date_set[0: 10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "thepiratefilmes2 benign\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from keras.preprocessing import sequence\n",
    "from keras.models import Sequential\n",
    "from keras.layers.core import Dense, Dropout, Activation\n",
    "from keras.layers.embeddings import Embedding\n",
    "from keras.layers.recurrent import LSTM\n",
    "import sklearn\n",
    "from sklearn.model_selection import train_test_split\n",
    "#%%\n",
    "# date_set[0: 10]\n",
    "features = [i[1] for i in date_set]   #提取域名\n",
    "label = [i[0] for i in date_set]      #提取标签\n",
    "print(features[1], label[1])\n",
    "valid_chars = {x:idx+1 for idx, x in enumerate(set(''.join(features)))} #构造检索字典\n",
    "y = [0 if x == 'benign' else 1 for x in label]   #目标值修改为0或1\n",
    "max_features = len(valid_chars) + 1  #？？？\n",
    "maxlen = np.max([len(x) for x in features])   #获得输入特征的最大长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "def process_features(valid_chars, features, maxlen):\n",
    "    \"\"\"将特征替换为 检索字典的值 并根据最长特征长度 构造每个特征 无值填充为0\"\"\"\n",
    "    X = [[valid_chars[y] for y in x] for x in features]\n",
    "    X = sequence.pad_sequences(X, maxlen=maxlen)\n",
    "    X = np.array(X)\n",
    "    return X\n",
    "X = process_features(valid_chars, features, maxlen)\n",
    "y = np.array(y)\n",
    "# print(x_train[0: 2], type(x_train))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From D:\\py\\anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Colocations handled automatically by placer.\n",
      "WARNING:tensorflow:From D:\\py\\anaconda\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "embedding_1 (Embedding)      (None, 63, 128)           4992      \n",
      "_________________________________________________________________\n",
      "lstm_1 (LSTM)                (None, 128)               131584    \n",
      "_________________________________________________________________\n",
      "dropout_1 (Dropout)          (None, 128)               0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 1)                 129       \n",
      "_________________________________________________________________\n",
      "activation_1 (Activation)    (None, 1)                 0         \n",
      "=================================================================\n",
      "Total params: 136,705\n",
      "Trainable params: 136,705\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "WARNING:tensorflow:From D:\\py\\anaconda\\lib\\site-packages\\tensorflow\\python\\ops\\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use tf.cast instead.\n",
      "Train on 1577626 samples, validate on 175292 samples\n",
      "Epoch 1/3\n",
      "1577626/1577626 [==============================] - 3511s 2ms/step - loss: 0.0698 - acc: 0.9758 - val_loss: 0.0354 - val_acc: 0.9883\n",
      "Epoch 2/3\n",
      "1577626/1577626 [==============================] - 3592s 2ms/step - loss: 0.0336 - acc: 0.9889 - val_loss: 0.0285 - val_acc: 0.9902\n",
      "Epoch 3/3\n",
      "1577626/1577626 [==============================] - 3578s 2ms/step - loss: 0.0280 - acc: 0.9907 - val_loss: 0.0240 - val_acc: 0.9917\n",
      "花费时间为10681.978999853134\n",
      "438230/438230 [==============================] - 261s 595us/step\n",
      "评分: 0.025627051007510174\n",
      "测试集准确率: 0.9911941218081829\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0 26 31 28  9 26 31 15 20 26 31 31\n",
      "  5 30  9 14  4  6 31 30 27  3  7  9  4  3 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999992]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  6  9  2 20  8  3 12  2  7 15 28  9 20 26  6]\n",
      "预测倾向为 0\n",
      "真实倾向为 [3.1769276e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 15\n",
      "  2  1 14 14  3 31  2 33 33  9 18  7  8  2  4]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9998009]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  9 13  8  3 20 30 27 28  3 28  3 31 14  3]\n",
      "预测倾向为 0\n",
      "真实倾向为 [1.9311905e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1\n",
      " 28 20 33  8 12  3 11 15 31 10 18  4 10 28 25]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999664]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  5  7  9  8 31 14  9 15]\n",
      "预测倾向为 0\n",
      "真实倾向为 [1.7255545e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 18\n",
      "  9 24  4  3 30 31  1  4  7 25 10  1 25  9  6]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.9999867]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 13  4  8 24 30  9\n",
      "  7  9  8 30 31 15  5 30 18 26 13 26 14 30  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999977]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  1 12 14  7]\n",
      "预测倾向为 0\n",
      "真实倾向为 [6.279349e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2\n",
      "  8 25 18 13 18 33 11 27  6  9 25 20  5 31 14]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999785]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 14 30 31  8  3  4 30 20 20]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00071317]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 29 16 20\n",
      " 15 30 31 24 10 31 33 32 31 15  5 11 30 17 13]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99998724]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 25 12  2 31 13  3 31\n",
      " 30  7 12 26  3  1 26 20 30 20  8  2 25  2 27]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999726]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      " 31  2 11 30  9 13 27  3 11  3 20  2 20  3  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999993]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0 31  3]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00403842]\n",
      "---原域名为： [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
      " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 2 4]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00174046]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 32 18 32  8 19  6 28  4  8 19 25]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99555266]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0 12 33 20 15 13 31 26 20 31 30 20  3 30 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9997815]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 18 30 26\n",
      " 37  7 15 13 30 27 10 14 31 14 13 34 37  3  3]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999106]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  2 15 25  8  2 30 12 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.03632283]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 37  5 25 15 31\n",
      "  3  8  3  5  3 13 12 30 20 26 12  3 37  6 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999356]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 27\n",
      " 18 31  3 18  4 20 31 13 13  5  6 14 24 28 10]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999906]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 14 33 14 30 25  1  6 27 24  1  5  6]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999796]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 14  9 13 20  7 26 26 27  4]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00023416]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  4 20 27\n",
      "  7 12  8 37  8 14  7 12  6  9 24 33 27 24 16]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99998844]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 13  4 24 25 26  7\n",
      "  7 26  1 13 30 27 15 30  9 20  7 26 31 31 25]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999833]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 17 27 11\n",
      " 33 27 15 31 28  1  4 32 16 32 12 20 32 17 29]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999738]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0 13  8  2 18 15 13 18 25]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.87991655]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 14 12 11 25 26 13 10  5  1  1 33 24]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9998905]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 31  7  9 24 12 13 26  3 28]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00131646]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0 31 28  3 13 15  5 26 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00012964]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  7  1 33\n",
      "  4  4 33 33 16 33 10  7  6 23 32  5 12 17 20]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999852]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1 13 28 27  3  7 30\n",
      " 15  6 12 26 25  9 20 30  3 20 30 37  2 24  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999989]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 18 14  9 14  1  3 27 15  9 13  6]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00329462]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  4 30 14 27  9 28 30 27]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00050813]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0 14  7  3 15  3  1  9 13 28  3 15 26 27]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.0002608]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0 27 27 13]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.000211]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 11\n",
      " 30 28  5 15 33  1 14 10  8 31 26 13  5 20 15]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999933]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 27\n",
      "  9 20 25 26 13 15  3  2 12 30  9  1 13 26 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00106838]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  2  9 33 25 14  3 13 15  5  2  7 18  6  1]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99996126]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0 11 14 14 30 28 26 20]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99800664]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 14\n",
      " 13  9 14 26 13 14 30 15 15 31  5  2 13  8  4]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00102282]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 31 10  2  3 13 26 31 14  3 27 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [1.40964985e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      " 26 26 18 18 26 20  4  3 20 27 26 12  6 31  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.999999]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  9 24 28 11  3 20  3 13 30  3 20  3 10  4]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999762]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      " 14 12 20 12 26 13 26 13 24  6  3 15  3 20  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999627]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1\n",
      " 26  8  7 20  8 26  7  7 14 12 28 30  1 12 30]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.999959]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 20 26 13 31 27 20 13 33  7  2 20 26]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.8350431]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 28 35  9  5 11 26 12 20  3 25 18  3]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00077441]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0 14  2 25 26  8  6 10]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9997997]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0 25 25 37 30  5  6 14  7  3  6 24  9  5  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99997663]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 33\n",
      "  2  5 13  5 10  2 26 10  5  1 33  5  5 27 31]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999949]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  8 27 28 15\n",
      " 26 13 30  9 20 30 13 18  2 15 31 18  3  8  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999902]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 12 13 30  5 33 15 24  2 26  1 24  2]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99972546]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  9 37  9 12 26 17 10 38 32 31  4 25 31 14 30]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999722]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0 27  4  2  5  3  9  8  3 28 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00097084]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  7\n",
      " 10 14  4 14 11  7 25 31  5 25  9 14 20 18 26]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999938]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0 20 30  8  4 15 14  9 30 20 15]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00023878]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  3 26 15 25]\n",
      "预测倾向为 0\n",
      "真实倾向为 [5.248189e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 20\n",
      " 11 31 18 25 14 10  8 12 26  3 25 10  6 13 30]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999864]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 30\n",
      " 26 26 12 27  5  8 11  7 20  1 28 30 18 28 20]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999936]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 20 12 10\n",
      " 19 15  7  7 18  8 11 12  1 12 10  9  8 16 34]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999326]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 36  9  7\n",
      "  6 24 28 11 11 24 16 19 34  6 31 15  8 37  4]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9998379]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 27\n",
      " 24 31  6  8  4 14 12 15 15 26  4 27  9 13 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9847254]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 33 25  1  3 26  7\n",
      "  7 26  1 13 30 27 15 30  9 20  7 26 31 31 25]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999931]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 18\n",
      " 18 30  8 27 31  3  9 11  7 20 13 13 15  6 15]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99997544]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 15\n",
      " 26 31 15 35 26 20 25 30 13  9 20 28 26 20 15]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.0005776]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 27\n",
      "  1 18 26 18  6 13 12 13 24 15  7 10  4  3  9]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999901]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 24  9 13 12 14 13 26 31 31]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00014412]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 15 33 25 15 31 20 15 12  5 11 11 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99775624]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2 20 30 25 26 13\n",
      " 31 30 12  3 12 26 12  3 28  2 12  3 20 27  3]\n",
      "预测倾向为 0\n",
      "真实倾向为 [1.0728836e-06]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 10  6 28  6  3  7 30\n",
      " 15  6 12 26 25  9 20 30  3 20 30 37  2 24  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99993086]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  3\n",
      "  2  2  8 33 33 10 30 13 30 31 11  2 15  6 18]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999906]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 27  3 28 14 26 13  1  9 33]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.01344454]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 14 37  7 27\n",
      " 28  3 27  4  2 31  7  3 37  3 13  9 10  9 18]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999666]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  3 28 26 13 30 27  3 20  1 26 12 26 13  3  7]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00028756]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  4 12 14  9 13 20  9  8 13  3 15 30 31]\n",
      "预测倾向为 0\n",
      "真实倾向为 [2.95043e-06]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0 36 29 23 35 17 38 32 34]\n",
      "预测倾向为 0\n",
      "真实倾向为 [5.4836273e-06]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0 25  4  8  6 26 31 15 20 26 31 31\n",
      "  5 30  9 14  4  6 31 30 27  3  7  9  4  3 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999297]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  5 12 30  9  1 28]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.44972882]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  4\n",
      " 27  5  1 26 24 13 31 26 14  1 27  8  1 30 33]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999348]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0 28 30 20  3  3  7]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00097653]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 27\n",
      "  3 20  3 12 30  3 20  8 26  3 13  4 26  3 12]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00020972]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0 15 13 30 14 31 15 26 13]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.00011998]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  1 30 13 31 15  9  4 30  9 15 30 15  7 26]\n",
      "预测倾向为 0\n",
      "真实倾向为 [1.7374754e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0 27 10  5  7  7 26  3 31  2 13 26\n",
      " 12 26  4  6 12 13  3 15  9 13  6 31  3  8 14]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999985]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 18 28\n",
      " 33 10 31 30 18  3 15  4 13 30 20 26 37  3 12]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999945]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 28\n",
      "  6 26 26  4  9 11 11 31 14 31 25  5 31  1 18]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999801]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 30 24 15 10  3 20 27  9 13 28  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999547]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0 24  3 15 26 13  1  9 13 12]\n",
      "预测倾向为 0\n",
      "真实倾向为 [0.0004825]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 31 26  3 13 27  4 28 26 12 30  3]\n",
      "预测倾向为 0\n",
      "真实倾向为 [4.5359135e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      " 15 15  3 28 26 13 26 13 24  6  3 15  3 20  5]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999933]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  8  3 27  6  4 26 37]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9983545]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  6 26  1 26\n",
      "  3 13 12 26 20 31  7  3 25 26 15  2 31  2  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999523]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  1  3 33 26 28  3 30  7]\n",
      "预测倾向为 0\n",
      "真实倾向为 [3.8981438e-05]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0 18  1 10  6 33 14  5 13 10 14 30  2]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999825]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  9 24  5 31  9 13 27  3 11  3 20  2 20  3  7]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999999]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  9\n",
      " 10  2 12 28 13 30  6 11 28 18 11 13 33 26  6]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.9999659]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 14  5 31  1  4  8 28 25 18 20 24]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99907124]\n",
      "---原域名为： [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0 14  4 25  6 26 14 30 27 15  9 28]\n",
      "预测倾向为 1\n",
      "真实倾向为 [0.99999815]\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import time\n",
    "def show_train_history(train_history,train, velidation):\n",
    "    \"\"\"\n",
    "    可视化训练过程 对比\n",
    "    :param train_history:\n",
    "    :param train:\n",
    "    :param velidation:\n",
    "    :return:\n",
    "    \"\"\"\n",
    "    plt.plot(train_history.history[train])\n",
    "    plt.plot(train_history.history[velidation])\n",
    "    plt.title(\"Train History\")   #标题\n",
    "    plt.xlabel('Epoch')    #x轴标题\n",
    "    plt.ylabel(train)  #y轴标题\n",
    "    plt.legend(['train', 'test'], loc='upper left')  #图例 左上角\n",
    "    plt.show()\n",
    "\n",
    "def build_model(max_features, maxlen):\n",
    "    \"\"\" 定义模型 \"\"\"\n",
    "    model = Sequential()\n",
    "    model.add(Embedding(input_dim=max_features, output_dim=128, input_length=maxlen))\n",
    "    model.add(LSTM(128))\n",
    "    model.add(Dropout(0.5))\n",
    "    model.add(Dense(1))\n",
    "    model.add(Activation('sigmoid'))\n",
    "    model.summary()\n",
    "    \n",
    "    model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])\n",
    "\n",
    "    return model\n",
    "def run():\n",
    "    \n",
    "    model = build_model(max_features, maxlen) \n",
    "    x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2)   #训练集测试集切割\n",
    "    \n",
    "    start_time = time.time()\n",
    "    history = model.fit(x_train, y_train, epochs=3, batch_size=128, shuffle=True, validation_split=0.1)   #训练\n",
    "    end_time = time.time()\n",
    "    print(\"花费时间为{}\".format(end_time-start_time))\n",
    "    \n",
    "    model.save('./model/DGA_predict_LSTM_V1.h5')\n",
    "    \n",
    "    score, acc = model.evaluate(x_test, y_test, batch_size=128)\n",
    "    print('评分:', score)\n",
    "    print('测试集准确率:', acc)\n",
    "    \n",
    "    \"\"\"可视化训练过程\"\"\"\n",
    "    show_train_history(history, 'acc', 'val_acc')    # 训练集准确率与验证集准确率 折线图\n",
    "    show_train_history(history, 'loss', 'val_loss')  # 训练集误差率与验证集误差率 折线图\n",
    "    \n",
    "    predect_label = model.predict(x_test)\n",
    "    for (a, b, c) in zip(y_test[0: 100], x_test[0: 100], predect_label[0: 100]):\n",
    "        print(\"---原域名为：\", b)\n",
    "        print(\"预测倾向为\", a)\n",
    "        print(\"真实倾向为\", c)\n",
    "    \n",
    "\n",
    "run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n",
      "  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 14\n",
      " 29 24 27  7  6 35 14 24 34  7 17 23 24 13 22] 0\n",
      "50000/50000 [==============================] - 33s 652us/step\n",
      "1.8541112198638916 0.67676\n"
     ]
    }
   ],
   "source": [
    "from keras.models import load_model\n",
    "model = load_model('./model/DGA_predict_LSTM_V2.h5')\n",
    "score, acc = model.evaluate(X[0: 50000], y[0: 50000], batch_size=128)\n",
    "print(score, acc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(3, 156), (0, 132), (2, 124), (4, 158)]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = [(0, 132), (2, 124), (3, 156), (4, 158)]\n",
    "shuffle(a)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "if True:\n",
    "    print(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
